home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / ipport / webster.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-11-18  |  4.0 KB  |  135 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Webster Client"
  5.    ClientHeight    =   3360
  6.    ClientLeft      =   1065
  7.    ClientTop       =   2010
  8.    ClientWidth     =   5040
  9.    Height          =   3765
  10.    Left            =   1005
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3360
  13.    ScaleWidth      =   5040
  14.    Top             =   1665
  15.    Width           =   5160
  16.    Begin IPPORT IPPort1 
  17.       EOL             =   ""
  18.       InBufferSize    =   2048
  19.       Left            =   0
  20.       LocalPort       =   0
  21.       OutBufferSize   =   2048
  22.       Port            =   0
  23.       Top             =   1320
  24.    End
  25.    Begin TextBox tDesc 
  26.       Height          =   2895
  27.       Left            =   0
  28.       MultiLine       =   -1  'True
  29.       ScrollBars      =   3  'Both
  30.       TabIndex        =   3
  31.       Top             =   480
  32.       Width           =   5055
  33.    End
  34.    Begin CommandButton bDefine 
  35.       Caption         =   "Define"
  36.       Default         =   -1  'True
  37.       Height          =   375
  38.       Left            =   3720
  39.       TabIndex        =   2
  40.       Top             =   60
  41.       Width           =   1215
  42.    End
  43.    Begin TextBox tWord 
  44.       Height          =   285
  45.       HideSelection   =   0   'False
  46.       Left            =   720
  47.       TabIndex        =   0
  48.       Top             =   120
  49.       Width           =   2775
  50.    End
  51.    Begin Label Label1 
  52.       BackStyle       =   0  'Transparent
  53.       Caption         =   "Word:"
  54.       Height          =   255
  55.       Left            =   120
  56.       TabIndex        =   1
  57.       Top             =   150
  58.       Width           =   735
  59.    End
  60. Sub bDefine_Click ()
  61. IPPort1.EOL = Chr$(10) 'talking text to Unix host
  62. 'first check for a word
  63. If Trim$(tWord) = "" Then
  64.     MsgBox "Define what? Please enter a word first..."
  65.     Exit Sub
  66. End If
  67. On Error GoTo ErrorHandling
  68. 'if not connected yet, then connect
  69. If Not IPPort1.Connected Then
  70.     'set address and port of webster host in Indiana
  71.     IPPort1.HostAddress = "129.79.254.195"
  72.     IPPort1.Port = 2627
  73.     'now try to connect
  74.     MousePointer = 11
  75.     tDesc = "Connecting to Webster host..."
  76.     IPPort1.Connected = True
  77.     'wait for connection to take place
  78.     '(using a timer would be more appropriate here)
  79.     For i = 1 To 500000
  80.         If IPPort1.Connected Then Exit For
  81.         DoEvents
  82.     Next i
  83.     'connection is taking too long
  84.     If i = 50000 Then
  85.         IPPort1.Connected = False
  86.         MsgBox "Timeout while trying to connect. Please try again later."
  87.         MousePointer = 0
  88.         Exit Sub
  89.     End If
  90. End If
  91. 'connection is made, so let's define word
  92. tDesc = "Making request..."
  93. IPPort1.DataToSend = "DEFINE " & tWord & Chr$(10)
  94. Exit Sub
  95. ErrorHandling:
  96.     MousePointer = 0
  97.     IPPort1.Connected = False
  98.     MsgBox "ERROR: " & Error$
  99.     Exit Sub
  100. End Sub
  101. Sub Form_Load ()
  102. tDesc = Chr$(13) & Chr$(10) & "This is a very simple Webster client." & Chr$(13) & Chr$(10)
  103. tDesc = tDesc & Chr$(13) & Chr$(10) & "It connects to a dictionary host in Indiana." & Chr$(13) & Chr$(10)
  104. tDesc = tDesc & Chr$(13) & Chr$(10) & "You can enter text above, or just" & Chr$(13) & Chr$(10)
  105. tDesc = tDesc & Chr$(13) & Chr$(10) & "doubleclick a word here."
  106. End Sub
  107. Sub Form_Resize ()
  108. tDesc.Width = ScaleWidth
  109. tDesc.Height = ScaleHeight - tDesc.Top
  110. bDefine.Left = ScaleWidth - bDefine.Width - 120
  111. tWord.Width = bDefine.Left - 240 - tWord.Left
  112. End Sub
  113. Sub IPPort1_DataIn (Text As String, EOL As Integer)
  114. Me.MousePointer = 0
  115. 'start of a new description...
  116. If tDesc = "Making request..." Then
  117.     tDesc = ""
  118.     MousePointer = 0
  119. End If
  120. If EOL Then Text = Text & Chr$(13) & Chr$(10)
  121. tDesc.SelStart = Len(tDesc)
  122. tDesc.SelText = Text
  123. End Sub
  124. Sub IPPort1_Disconnected (StatusCode As Integer, Description As String)
  125. MousePointer = 0
  126. End Sub
  127. Sub tDesc_DblClick ()
  128. tWord = tDesc.SelText
  129. bDefine = True
  130. 'select word
  131. tWord.SelStart = 0
  132. tWord.SelLength = Len(tWord)
  133. tWord.SetFocus
  134. End Sub
  135.